﻿using System;
using Microsoft.Extensions.DependencyInjection;
using Solution.Application.Modules;

namespace Solution.Application.Extensions
{
    public static class RabbitMQExtensions
    {
        public static void AddCAPRabbitMQ(this IServiceCollection services, RabbitMQOption rabbitMQOptions)
        {
            services.AddCap(options =>
            {

                options.UseMySql("Server=ilater.com;Port=63306;Database=test-db; User=root;Password=jIk%^(Ayg~?$9Sb,kcWo;pooling=True;minpoolsize=1;maxpoolsize=100;connectiontimeout=180");
                options.UseRabbitMQ(configure =>
                {
                    configure.HostName = rabbitMQOptions.HostName;
                    configure.Port = rabbitMQOptions.Port;
                    configure.VirtualHost = rabbitMQOptions.VirtualHost;
                    configure.UserName = rabbitMQOptions.UserName;
                    configure.Password = rabbitMQOptions.Password;
                });
                options.FailedRetryCount = 5;
            });
        }
    }
}